package visualizer.google.concrete;

import java.util.LinkedHashMap;
import java.util.Map;

import visualizer.countries.CountryMap;
import visualizer.google.GoogleService;

public class GlobalAnalyzer {
	private CountryMap countries = new CountryMap();
	private GoogleService service;
	
	public GlobalAnalyzer(GoogleService service) {
		this.service = service;
	}
	
	public Map<String, Integer> getEstimatedHitsPerCountry(String search)
	{
		Map<String, Integer> result = new LinkedHashMap<String, Integer>();
		for (String country : countries.keySet()) {
			result.put(country, getEstimatedHits(country, search));
		}
		return result;
	}
	
	public int getEstimatedHits(String country, String search)
	{
		return service.execute(search + " site:." + country).getEstimatedResultCount();
	}
}
